﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>BayGUI - Editor</title>
    <link href="../../../jquery-easyui-themes/default/easyui.css" rel="stylesheet" />
    <link href="../../../jquery-easyui-themes/icon.css" rel="stylesheet" />
    <link href="../../../icons/icon-all.css" rel="stylesheet" />

    <script src="../../../jquery/jquery-1.11.1.js" type="text/javascript"></script>
    <script src="../../../jquery-easyui-1.4/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../../jquery-easyui-1.4/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>

    <script src="../../../jquery.jdirk.js" type="text/javascript"></script>
    <script src="../../../jeasyui-extensions/jeasyui.extensions.js" type="text/javascript"></script>

    <script src="../../../jeasyui-extensions/jeasyui.extensions.linkbutton.js"></script>
    <script src="../../../jeasyui-extensions/jeasyui.extensions.menu.js" type="text/javascript"></script>
    <script src="../../../jeasyui-extensions/jeasyui.extensions.panel.js" type="text/javascript"></script>
    <script src="../../../jeasyui-extensions/jeasyui.extensions.window.js" type="text/javascript"></script>
    <script src="../../../jeasyui-extensions/jeasyui.extensions.dialog.js" type="text/javascript"></script>
    <script src="../../../jeasyui-extensions/jeasyui.extensions.tabs.js" type="text/javascript"></script>
    <script src="../../../jeasyui-extensions/jquery.toolbar.js" type="text/javascript"></script>

    <script src="jeasyui.bayseditor.js"></script>

    <script type="text/javascript">
        $(function () {
            var code = $.util.request["code"],
                editor = $.baygui.editor({
                    shipQueryParams: { code: code },
                    shipMethod: "get",
                    shipUrl: "ship-data.json",
                    baysMethod: "get",
                    baysQueryParams: { code: code },
                    baysUrl: "bays-data.json",
                    saveUrl: "./save.do",
                    saveMethod: "post",
                    baysContainer: "#baysContainer",
                    onSaveError: $.easyui.ajaxError()
                });
            
            $("#btnAddBay").click(function () {
                editor.showAddBayDialog();
            });

            $("#btnInsertBay").click(function () {
                var bay = editor.getBay();
                if (!bay) { return $.messager.show("请先选定一个贝位"); }
                editor.showInsertBayDialog(bay.bayNo);
            });

            $("#btnRemoveBay").click(function () {
                var bay = editor.getBay();
                if (!bay) { return $.messager.show("请先选定一个贝位"); }
                $.messager.confirm("操作提醒", "您确定要删除贝位 \"" + bay.bayNo + "\" (点击\"保存所有数据\"按钮后才能生效并保存至数据库)？", function (c) {
                    if (c) { editor.removeBay(bay.bayNo); }
                });
            });

            $("#btnDisableCell").click(function () {
                var cell = editor.getCell();
                if (!cell) { return $.messager.show("请先选定一个贝位单元格"); }
                editor.disableCell(cell.bayCellNo);
            });

            $("#btnEnableCell").click(function () {
                var cell = editor.getCell();
                if (!cell) { return $.messager.show("请先选定一个贝位单元格"); }
                editor.enableCell(cell.bayCellNo);
            });

            $("#btnDisableRow").click(function () {
                var cell = editor.getCell();
                if (!cell) { return $.messager.show("请先选定一个贝位单元格"); }
                editor.disableRow(cell.bayNo, cell.rowNo);
            });

            $("#btnEnableRow").click(function () {
                var cell = editor.getCell();
                if (!cell) { return $.messager.show("请先选定一个贝位单元格"); }
                editor.enableRow(cell.bayNo, cell.rowNo);
            });

            $("#btnSave").click(function () { editor.save(); });
            
        });
    </script>
    <style type="text/css">
    </style>

</head>
<body>
    <div class="easyui-layout" data-options="fit: true">

        <div data-options="region: 'north', border: false, split: false" style="height: 94px;">
            <div class="easyui-toolbar">
                <a id="btnAddBay" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-add'">增加一个贝位</a>
                <a id="btnInsertBay" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-hamburg-cost'">在选定的贝位前插入一个贝位</a>
                <a id="btnRemoveBay" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-remove'" style="margin-left: 69px;">删除选定的贝位</a>
            </div>
            <div class="easyui-toolbar">
                <a id="btnDisableCell" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-standard-cancel'">禁用选定贝位单元格</a>
                <a id="btnEnableCell" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-standard-accept'">启用选定贝位单元格</a>
                <a id="btnDisableRow" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-standard-cross'" style="margin-left: 80px;">禁用选定贝位单元格所在行(纵向)</a>
                <a id="btnEnableRow" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-hamburg-check'">启用选定贝位单元格所在列(纵向)</a>
            </div>
            <div class="easyui-toolbar">
                <a id="btnSave" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-save'">保存所有数据</a>
                <span>该按钮点击后会报错 404，因为此 BayGUI 组件的 saveUrl 属性所表示的 url 服务端地址实际上无效，此处仅模拟点击效果。</span>
                <a href="API 说明.txt" target="_blank">查看 API 说明</a>
            </div>
        </div>

        <div data-options="region: 'center'">
            <div id="baysContainer" data-options="fit: true, border: false"></div>
        </div>
    </div>
</body>
</html>
